package com.mxprojects.constructors
{
	import com.mxprojects.gui.Styles;
	
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	import flash.geom.Rectangle;
	
	public class TextScroller extends MovieClip
	{
		public var startHeight:int;
		public var startWidth:int;
		
		private var target:SimpleTextField;
		
		public function TextScroller(textFieldToScroll:SimpleTextField = null){
			//set the defaults
			startHeight = height;
			startWidth = width;
			
			//set the look
			Styles.setProperties(this, ".formScroller");
			
			//build it
			if(textFieldToScroll != null){
				this.target = textFieldToScroll;
				x = target.x + target.width;
				y = target.y;
				height = target.height;
				name = "scroller";

				//make sure there is something to scroll
				if(target.maxScrollV > 1){
					var scrollHeight:int = target.height - target.maxScrollV;
					if(scrollHeight > startHeight){
						height = target.height - target.maxScrollV;
					}else{
						height = startHeight;
					}					
				}else{
					//otherwise hide it
					visible = false;
				}
			}
		}
	}
}